$('document').ready(function() {

    //删除
    function deletecontent() {
        $("#delete").click(function() {
            console.log($(this).attr('value'))
            contentid = $(this).attr('value')
            $.ajax({
                    type: "get",
                    url: "http://111.229.120.67/stu/del-errbook-ques", //接口
                    data: {
                        statusCode: 0,
                        qid: contentid, //题目id
                    },
                    dataType: "json",
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function(data) { //获取题目
                        console.log(data)
                            // console.log(data.page.nextPageNum)
                        nextPage = data.page.nextPageNum + 1
                            // console.log(nextPage)
                        if (data.statusCode == 0) {
                            if (data.page.errquestionList.length !== 0) {
                                var ContentTitle
                                $.each(data.page.errquestionList, function(i, n) {
                                    // console.log(data.page.errquestionList[i].type)
                                    if (data.page.errquestionList[i].type == 1) {
                                        var option = ''
                                            // console.log(190)
                                            // console.log(data.page.errquestionList[i].options)
                                        $.each(data.page.errquestionList[i].options, function(j, x) {
                                                // console.log(x)
                                                option += `<li><input type='radio' name="radin">` + x + `</li>`
                                            })
                                            // console.log(option)
                                            // console.log(1116)
                                            // console.log(data.page.errquestionList[i].content)
                                            // console.log(data.page.errquestionList[i].options_answers[0])
                                            // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                            // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]];
                                        $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                            // console.log(data.page.errquestionList[i].options[x])
                                            curret_answer = `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                        })
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                        // console.log(111)
                                        // console.log(ContentTitle)
                                    } else if (data.page.errquestionList[i].type == 2) {
                                        var option
                                            // console.log(190)
                                            // console.log(data.page.errquestionList[i].options)
                                        $.each(data.page.errquestionList[i].options, function(j, x) {
                                            // console.log(x)
                                            option += `<li><input type='checkbox' name="checkbox">` + x + `</li>`
                                        })
                                        var curret_answer = ''
                                        $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                                console.log(x)
                                                curret_answer += `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                            })
                                            // console.log(option)
                                            // console.log(1116)
                                            // console.log(data.page.errquestionList[i].content)
                                            // console.log(data.page.errquestionList[i].options_answers[0])
                                            // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                            // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[answers]];
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                    } else if (data.page.errquestionList[i].type == 3) {
                                        if (data.page.errquestionList[i].text_answer[0] == "f") {
                                            var curret_answer = "错"
                                        } else {
                                            var curret_answer = "对"
                                        }
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                <li><input type='radio' name="radin">对</li>
                                <li><input type='radio' name="radin">错</li>
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    } else if (data.page.errquestionList[i].type == 4) {
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    } else if (data.page.errquestionList[i].type == 5) {
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    }
                                    // console.log($(".erron-none"))
                                    $(".erron-none").html(ContentTitle)
                                    answer()
                                    deletecontent()
                                    nextcontent()
                                        //
                                })
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('未获取到题目')
                                $('#myModal-public-body').html('暂无错题')
                            }
                        }
                    }
                })
                //$("#erron-content-title").load(location.href + "erron-content-title")
        })
    }
    //下一题
    function nextcontent() {
        $("#next").click(function() {
            console.log(nextPage) //获取当前页页号
            $.ajax({
                    type: "get",
                    url: "http://111.229.120.67/stu/allerr-question", //接口
                    data: {
                        nextPageNum: "nextPageNum",
                        //获取下一题
                    },
                    dataType: "json",
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function(data) { //获取题目
                        console.log(data)
                            // console.log(data.page.nextPageNum)
                        nextPage = data.page.nextPageNum + 1
                            // console.log(nextPage)
                        if (data.statusCode == 0) {
                            if (data.page.errquestionList.length !== 0) {
                                var ContentTitle
                                $.each(data.page.errquestionList, function(i, n) {
                                    // console.log(data.page.errquestionList[i].type)
                                    if (data.page.errquestionList[i].type == 1) {
                                        var option = ''
                                            // console.log(190)
                                            // console.log(data.page.errquestionList[i].options)
                                        $.each(data.page.errquestionList[i].options, function(j, x) {
                                                // console.log(x)
                                                option += `<li><input type='radio' name="radin">` + x + `</li>`
                                            })
                                            // console.log(option)
                                            // console.log(1116)
                                            // console.log(data.page.errquestionList[i].content)
                                            // console.log(data.page.errquestionList[i].options_answers[0])
                                            // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                            // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]];
                                        $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                            // console.log(data.page.errquestionList[i].options[x])
                                            curret_answer = `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                        })
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                        // console.log(111)
                                        // console.log(ContentTitle)
                                    } else if (data.page.errquestionList[i].type == 2) {
                                        var option
                                            // console.log(190)
                                            // console.log(data.page.errquestionList[i].options)
                                        $.each(data.page.errquestionList[i].options, function(j, x) {
                                            // console.log(x)
                                            option += `<li><input type='checkbox' name="checkbox">` + x + `</li>`
                                        })
                                        var curret_answer = ''
                                        $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                                console.log(x)
                                                curret_answer += `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                            })
                                            // console.log(option)
                                            // console.log(1116)
                                            // console.log(data.page.errquestionList[i].content)
                                            // console.log(data.page.errquestionList[i].options_answers[0])
                                            // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                            // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[answers]];
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                    } else if (data.page.errquestionList[i].type == 3) {
                                        if (data.page.errquestionList[i].text_answer[0] == "f") {
                                            var curret_answer = "错"
                                        } else {
                                            var curret_answer = "对"
                                        }
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                <li><input type='radio' name="radin">对</li>
                                <li><input type='radio' name="radin">错</li>
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    } else if (data.page.errquestionList[i].type == 4) {
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    } else if (data.page.errquestionList[i].type == 5) {
                                        ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                            `<div class="zhengque">
                                <p class="error-content-title-zhengwu">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                    }
                                    // console.log($(".erron-none"))
                                    $(".erron-none").html(ContentTitle)
                                    answer()
                                    deletecontent()
                                    nextcontent()
                                        //
                                })
                            } else {
                                $('#myModal-public').modal({})
                                $('#myModal-public h4').html('未获取到题目')
                                $('#myModal-public-body').html('暂无错题')
                            }
                        }
                    }

                })
                //$("#erron-content-title").load(location.href + "erron-content-title")
        })
    }
    //章节部分
    function chaptercolor() {
        $(".error-head-chapter  p").click(function() {
            $(this).attr("class", "cilck")
            $(this).siblings().attr("class", "")
                // $('.content').eq($(this).index()).addClass('erron-black');
                // $('.content').eq($(this).index()).siblings().removeClass('erron-black');
        })
    }

    var chapterid

    function chapterajax() { //根据章节请求错题
        $(".error-head-chapter p").click(function() {
            console.log(courseid)

            // console.log($(this).attr('value'))
            chapterid = $(this).attr('value')
                //$("#erron-content-title").load(location.href + "erron-content-title")
                // console.log(chapterid)
                // console.log(chapterid)
                // console.log(7899)
            $.ajax({ //请求所有章节错题
                type: "get",
                url: "http://111.229.120.67/stu/allerr-question", //接口
                data: {
                    course_id: courseid,
                    chapter_id: chapterid, //发送章节id
                },
                dataType: "json",
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) { //获取题目
                    console.log(data)
                        // console.log(data.page.nextPageNum)
                    nextPage = data.page.nextPageNum + 1
                        // console.log(nextPage)
                    if (data.statusCode == 0) {
                        if (data.page.errquestionList.length !== 0) {
                            var ContentTitle
                            $.each(data.page.errquestionList, function(i, n) {
                                // console.log(data.page.errquestionList[i].type)
                                if (data.page.errquestionList[i].type == 1) {
                                    var option = ''
                                        // console.log(190)
                                        // console.log(data.page.errquestionList[i].options)
                                    $.each(data.page.errquestionList[i].options, function(j, x) {
                                            // console.log(x)
                                            option += `<li><input type='radio' name="radin">` + x + `</li>`
                                        })
                                        // console.log(option)
                                        // console.log(1116)
                                        // console.log(data.page.errquestionList[i].content)
                                        // console.log(data.page.errquestionList[i].options_answers[0])
                                        // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                        // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]];
                                    $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                        // console.log(data.page.errquestionList[i].options[x])
                                        curret_answer = `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                    })
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                    // console.log(111)
                                    // console.log(ContentTitle)
                                } else if (data.page.errquestionList[i].type == 2) {
                                    var option
                                        // console.log(190)
                                        // console.log(data.page.errquestionList[i].options)
                                    $.each(data.page.errquestionList[i].options, function(j, x) {
                                        // console.log(x)
                                        option += `<li><input type='checkbox' name="checkbox">` + x + `</li>`
                                    })
                                    var curret_answer = ''
                                    $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                            console.log(x)
                                            curret_answer += `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                        })
                                        // console.log(option)
                                        // console.log(1116)
                                        // console.log(data.page.errquestionList[i].content)
                                        // console.log(data.page.errquestionList[i].options_answers[0])
                                        // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                        // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[answers]];
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                } else if (data.page.errquestionList[i].type == 3) {
                                    if (data.page.errquestionList[i].text_answer[0] == "f") {
                                        var curret_answer = "错"
                                    } else {
                                        var curret_answer = "对"
                                    }
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                <li><input type='radio' name="radin">对</li>
                                <li><input type='radio' name="radin">错</li>
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                } else if (data.page.errquestionList[i].type == 4) {
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                } else if (data.page.errquestionList[i].type == 5) {
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                }
                                // console.log($(".erron-none"))
                                $(".erron-none").html(ContentTitle)
                                answer()
                                deletecontent()
                                nextcontent()
                                    //
                            })
                        } else {
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('未获取到题目')
                            $('#myModal-public-body').html('暂无错题')
                        }
                    }
                }

            })

            $(".danxuan").click(function() { //请求章节错题类型1
                console.log(chapterid)
                $.ajax({
                        type: "get",
                        url: "http://111.229.120.67/stu/allerr-question", //接口
                        data: {
                            course_id: courseid,
                            chapter_id: chapterid, //
                            type: "1"
                        },
                        dataType: "json",
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(data) { //获取题目
                            console.log(data)
                                // console.log(data.page.nextPageNum)
                            nextPage = data.page.nextPageNum + 1
                                // console.log(nextPage)
                            if (data.statusCode == 0) {
                                if (data.page.errquestionList.length !== 0) {
                                    var ContentTitle
                                    $.each(data.page.errquestionList, function(i, n) {
                                        // console.log(data.page.errquestionList[i].type)
                                        if (data.page.errquestionList[i].type == 1) {
                                            var option = ''
                                                // console.log(190)
                                                // console.log(data.page.errquestionList[i].options)
                                            $.each(data.page.errquestionList[i].options, function(j, x) {
                                                    // console.log(x)
                                                    option += `<li><input type='radio' name="radin">` + x + `</li>`
                                                })
                                                // console.log(option)
                                                // console.log(1116)
                                                // console.log(data.page.errquestionList[i].content)
                                                // console.log(data.page.errquestionList[i].options_answers[0])
                                                // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                                // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]];
                                            $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                                // console.log(data.page.errquestionList[i].options[x])
                                                curret_answer = `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                            })
                                            ContentTitle = `
                            <div class="error-content-title">
                                <div class="dati">
                                    <p class="error-content-title-zhengwu ">答题</p>
                                    <p class="error-content-title-timu">
                                    ` + data.page.errquestionList[i].content + `
                                    </p>
                                    <ol class="dati-answer">
                                    ` + option + `
                                    </ol>
                                    <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                                </div>` +
                                                `<div class="zhengque">
                                    <p class="error-content-title-zhengwu ">正确答案</p>
                                    <div class="rightkey">
                                        ` + curret_answer + `
                                    </div>
                                    <div style="display:inline-flex;width:100%;">
                                    <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                    <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                     </div>
                                </div>
                        </div>`

                                            // console.log(111)
                                            // console.log(ContentTitle)
                                        }
                                        // console.log($(".erron-none"))
                                        $(".erron-none").html(ContentTitle)
                                        answer()
                                        deletecontent()
                                        nextcontent()
                                            //
                                    })
                                } else {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('暂无错题')
                                }
                            }
                        }

                    })
                    //$("#erron-content-title").load(location.href + "erron-content-title")
            })
            $(".duoxuan").click(function() { //请求章节错题类型2
                // console.log(chapterid)
                $.ajax({
                        type: "get",
                        url: "http://111.229.120.67/stu/allerr-question", //接口
                        data: {
                            course_id: courseid,
                            chapter_id: chapterid, //
                            type: "2"
                        },
                        dataType: "json",
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(data) { //获取题目
                            console.log(data)
                                // console.log(data.page.nextPageNum)
                            nextPage = data.page.nextPageNum + 1
                                // console.log(nextPage)
                            if (data.statusCode == 0) {
                                if (data.page.errquestionList.length !== 0) {
                                    var ContentTitle
                                    $.each(data.page.errquestionList, function(i, n) {
                                        // console.log(data.page.errquestionList[i].type)
                                        if (data.page.errquestionList[i].type == 2) {
                                            var option
                                                // console.log(190)
                                                // console.log(data.page.errquestionList[i].options)
                                            $.each(data.page.errquestionList[i].options, function(j, x) {
                                                // console.log(x)
                                                option += `<li><input type='checkbox' name="checkbox">` + x + `</li>`
                                            })
                                            var curret_answer = ''
                                            $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                                    console.log(x)
                                                    curret_answer += `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                                })
                                                // console.log(option)
                                                // console.log(1116)
                                                // console.log(data.page.errquestionList[i].content)
                                                // console.log(data.page.errquestionList[i].options_answers[0])
                                                // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                                // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[answers]];
                                            ContentTitle = `
                            <div class="error-content-title">
                                <div class="dati">
                                    <p class="error-content-title-zhengwu ">答题</p>
                                    <p class="error-content-title-timu">
                                    ` + data.page.errquestionList[i].content + `
                                    </p>
                                    <ol class="dati-answer">
                                    ` + option + `
                                    </ol>
                                    <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                                </div>` +
                                                `<div class="zhengque">
                                    <p class="error-content-title-zhengwu ">正确答案</p>
                                    <div class="rightkey">
                                        ` + curret_answer + `
                                    </div>
                                    <div style="display:inline-flex;width:100%;">
                                    <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                    <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                     </div>
                                </div>
                        </div>`

                                        }
                                        // console.log($(".erron-none"))
                                        $(".erron-none").html(ContentTitle)
                                        answer()
                                        deletecontent()
                                        nextcontent()
                                            //
                                    })
                                } else {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('暂无错题')
                                }
                            }
                        }
                    })
                    //$("#erron-content-title").load(location.href + "erron-content-title")
            })
            $(".panduan").click(function() { //请求章节错题类型3
                // console.log(chapterid)
                // console.log(666)
                $.ajax({
                        type: "get",
                        url: "http://111.229.120.67/stu/allerr-question", //接口
                        data: {
                            course_id: courseid,
                            chapter_id: chapterid, //
                            type: "3"
                        },
                        dataType: "json",
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(data) { //获取题目
                            console.log(data)
                            console.log(666)
                                // console.log(data.page.nextPageNum)
                            nextPage = data.page.nextPageNum + 1
                                // console.log(nextPage)
                            if (data.statusCode == 0) {
                                if (data.page.errquestionList.length !== 0) {
                                    var ContentTitle
                                    $.each(data.page.errquestionList, function(i, n) {
                                        // console.log(data.page.errquestionList[i].type)
                                        if (data.page.errquestionList[i].type == 3) {
                                            if (data.page.errquestionList[i].text_answer[0] == "f") {
                                                var curret_answer = "错"
                                            } else {
                                                var curret_answer = "对"
                                            }
                                            ContentTitle = `
                            <div class="error-content-title">
                                <div class="dati">
                                    <p class="error-content-title-zhengwu ">答题</p>
                                    <p class="error-content-title-timu">
                                    ` + data.page.errquestionList[i].content + `
                                    </p>
                                    <ol class="dati-answer">
                                    <li><input type='radio' name="radin">对</li>
                                    <li><input type='radio' name="radin">错</li>
                                    </ol>
                                    <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                                </div>` +
                                                `<div class="zhengque">
                                    <p class="error-content-title-zhengwu ">正确答案</p>
                                    <div class="rightkey">
                                        ` + curret_answer + `
                                    </div>
                                    <div style="display:inline-flex;width:100%;">
                                    <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                    <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                     </div>
                                </div>
                        </div>`
                                        }
                                        // console.log($(".erron-none"))
                                        $(".erron-none").html(ContentTitle)
                                        answer()
                                        deletecontent()
                                        nextcontent()
                                            //
                                    })
                                } else {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('暂无错题')
                                }
                            }
                        }
                    })
                    //$("#erron-content-title").load(location.href + "erron-content-title")
            })
            $(".tiankong").click(function() { //请求章节错题类型4
                // console.log(chapterid)
                $.ajax({
                        type: "get",
                        url: "http://111.229.120.67/stu/allerr-question", //接口
                        data: {
                            course_id: courseid,
                            chapter_id: chapterid, //
                            type: "4"
                        },
                        dataType: "json",
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(data) { //获取题目
                            console.log(data)
                                // console.log(data.page.nextPageNum)
                            nextPage = data.page.nextPageNum + 1
                                // console.log(nextPage)
                            if (data.statusCode == 0) {
                                if (data.page.errquestionList.length !== 0) {
                                    var ContentTitle
                                    $.each(data.page.errquestionList, function(i, n) {
                                        // console.log(data.page.errquestionList[i].type)
                                        if (data.page.errquestionList[i].type == 4) {
                                            ContentTitle = `
                            <div class="error-content-title">
                                <div class="dati">
                                    <p class="error-content-title-zhengwu ">答题</p>
                                    <p class="error-content-title-timu">
                                    ` + data.page.errquestionList[i].content + `
                                    </p>
                                    <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                    <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                                </div>` +
                                                `<div class="zhengque">
                                    <p class="error-content-title-zhengwu ">正确答案</p>
                                    <div class="rightkey">
                                        ` + data.page.errquestionList[i].text_answer + `
                                    </div>
                                    <div style="display:inline-flex;width:100%;">
                                    <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                    <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                     </div>
                                </div>
                        </div>`
                                        }
                                        $(".erron-none").html(ContentTitle)
                                        answer()
                                        deletecontent()
                                        nextcontent()
                                            //
                                    })
                                } else {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('暂无错题')
                                }
                            }
                        }

                    })
                    //$("#erron-content-title").load(location.href + "erron-content-title")
            })

            $(".wenda").click(function() { //请求章节错题类型5
                // console.log(chapterid)
                $.ajax({
                        type: "get",
                        url: "http://111.229.120.67/stu/allerr-question", //接口
                        data: {
                            course_id: courseid,
                            chapter_id: chapterid, //
                            type: "5"
                        },
                        dataType: "json",
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(data) { //获取题目
                            console.log(data)
                                // console.log(data.page.nextPageNum)
                            nextPage = data.page.nextPageNum + 1
                                // console.log(nextPage)
                            if (data.statusCode == 0) {
                                if (data.page.errquestionList.length !== 0) {
                                    var ContentTitle
                                    $.each(data.page.errquestionList, function(i, n) {
                                        // console.log(data.page.errquestionList[i].type)
                                        if (data.page.errquestionList[i].type == 5) {
                                            ContentTitle = `
                            <div class="error-content-title">
                                <div class="dati">
                                    <p class="error-content-title-zhengwu ">答题</p>
                                    <p class="error-content-title-timu">
                                    ` + data.page.errquestionList[i].content + `
                                    </p>
                                    <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                    <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                                </div>` +
                                                `<div class="zhengque">
                                    <p class="error-content-title-zhengwu">正确答案</p>
                                    <div class="rightkey">
                                        ` + data.page.errquestionList[i].text_answer + `
                                    </div>
                                    <div style="display:inline-flex;width:100%;">
                                    <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                    <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                     </div>
                                </div>
                        </div>`
                                        }
                                        // console.log($(".erron-none"))
                                        $(".erron-none").html(ContentTitle)
                                        answer()
                                        deletecontent()
                                        nextcontent()
                                            //
                                    })
                                } else {
                                    $('#myModal-public').modal({})
                                    $('#myModal-public h4').html('未获取到题目')
                                    $('#myModal-public-body').html('暂无错题')
                                }
                            }
                        }

                    })
                    //$("#erron-content-title").load(location.href + "erron-content-title")
            })
        })
    }
    //课程
    //获取课程
    $(".error-head-course").click(function() {
        $('.error-head-class').eq($(this).index()).addClass('black');
        $('.error-head-class').eq($(this).index()).siblings().removeClass('black');
    })

    function coursecolor() {
        $(".error-head-course p").click(function() {
            // var courseid = $(this).attr('value')
            // console.log(666)
            $(this).attr("class", "cilck")
            $(this).siblings().attr("class", "")
            $('.error-head-chapter').eq($(this).index()).addClass('black');
            $('.error-head-chapter').eq($(this).index()).siblings().removeClass('black');
        })
    }
    var courseid

    function courseajax() { //课程请求章节
        $(".error-head-course p").click(function() {
            courseid = $(this).attr('value')
                // console.log(courseid)
                //请求所有课程错题  
            console.log(courseid)
            $.ajax({
                type: "get",
                url: "http://111.229.120.67/stu/allerr-question", //接口
                data: {
                    course_id: courseid, //获取所有课程错题的参数名并返回课程id
                },
                dataType: "json",
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) { //获取题目
                    console.log(data)
                        // console.log(data.page.nextPageNum)
                    nextPage = data.page.nextPageNum + 1
                        // console.log(nextPage)
                    if (data.statusCode == 0) {
                        if (data.page.errquestionList.length !== 0) {
                            var ContentTitle
                            $.each(data.page.errquestionList, function(i, n) {
                                // console.log(data.page.errquestionList[i].type)
                                if (data.page.errquestionList[i].type == 1) {
                                    var option = ''
                                        // console.log(190)
                                        // console.log(data.page.errquestionList[i].options)
                                    $.each(data.page.errquestionList[i].options, function(j, x) {
                                            // console.log(x)
                                            option += `<li><input type='radio' name="radin">` + x + `</li>`
                                        })
                                        // console.log(option)
                                        // console.log(1116)
                                        // console.log(data.page.errquestionList[i].content)
                                        // console.log(data.page.errquestionList[i].options_answers[0])
                                        // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                        // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]];
                                    $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                        // console.log(data.page.errquestionList[i].options[x])
                                        curret_answer = `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                    })
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                    // console.log(111)
                                    // console.log(ContentTitle)
                                } else if (data.page.errquestionList[i].type == 2) {
                                    var option
                                        // console.log(190)
                                        // console.log(data.page.errquestionList[i].options)
                                    $.each(data.page.errquestionList[i].options, function(j, x) {
                                        // console.log(x)
                                        option += `<li><input type='checkbox' name="checkbox">` + x + `</li>`
                                    })
                                    var curret_answer = ''
                                    $.each(data.page.errquestionList[i].options_answers, function(j, x) {
                                            console.log(x)
                                            curret_answer += `<div>` + data.page.errquestionList[i].options[x] + `</div>`;

                                        })
                                        // console.log(option)
                                        // console.log(1116)
                                        // console.log(data.page.errquestionList[i].content)
                                        // console.log(data.page.errquestionList[i].options_answers[0])
                                        // console.log(data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[0]])
                                        // var curret_answer = data.page.errquestionList[i].options[data.page.errquestionList[i].options_answers[answers]];
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                ` + option + `
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`

                                } else if (data.page.errquestionList[i].type == 3) {
                                    if (data.page.errquestionList[i].text_answer[0] == "f") {
                                        var curret_answer = "错"
                                    } else {
                                        var curret_answer = "对"
                                    }
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <ol class="dati-answer">
                                <li><input type='radio' name="radin">对</li>
                                <li><input type='radio' name="radin">错</li>
                                </ol>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + curret_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                } else if (data.page.errquestionList[i].type == 4) {
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu ">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                } else if (data.page.errquestionList[i].type == 5) {
                                    ContentTitle = `
                        <div class="error-content-title">
                            <div class="dati">
                                <p class="error-content-title-zhengwu ">答题</p>
                                <p class="error-content-title-timu">
                                ` + data.page.errquestionList[i].content + `
                                </p>
                                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="请输入答案"></textarea>
                                <button type="button" id="answer" class="btn btn-large btn-block btn-primary">查看正确答案</button>
                            </div>` +
                                        `<div class="zhengque">
                                <p class="error-content-title-zhengwu">正确答案</p>
                                <div class="rightkey">
                                    ` + data.page.errquestionList[i].text_answer + `
                                </div>
                                <div style="display:inline-flex;width:100%;">
                                <button id="delete" style="width:50%" value="` + data.page.errquestionList[i].id + `" type="button" class="btn  btn-warning">删除本题</button>
                                <button id="next" style="width:50%" type="button" class="btn   btn-info">下一题</button>
                                 </div>
                            </div>
                    </div>`
                                }
                                // console.log($(".erron-none"))
                                $(".erron-none").html(ContentTitle)
                                answer()
                                deletecontent()
                                nextcontent()
                                    //
                            })
                        } else {
                            $('#myModal-public').modal({})
                            $('#myModal-public h4').html('未获取到题目')
                            $('#myModal-public-body').html('暂无错题')
                        }
                    }
                }
            })

            $.ajax({ //获取章节所用ajax
                type: "post",
                url: "http://111.229.120.67/gen/course-chap", //接口
                data: {
                    cid: courseid, //获取章节
                },
                dataType: "json",
                success: function(data) {
                    // console.log(data)
                    if (data.statusCode == 0) {
                        console.log(data)
                        var chapter
                        $.each(data.courseList, function(i, n) {
                            chapter = `
                            <p style=" display: inline-flex;" value="` + n.id + `">
                            <a href="#" style="display: block; text-align: center;"  >` + n.sectionName + `</a>
                        </p>`
                            $(".error-head-chapter").append(chapter)
                        })
                        chaptercolor()
                        chapterajax()

                    }
                },
                xhrFields: {
                    withCredentials: true
                },
            })
            $(".error-head-chapter").load(location.href + "error-head-chapter black");
            //$("#erron-content-title").load(location.href + "erron-content-title")
            // parent.location.reload()
        })
    }

    $.ajax({
        type: "get",
        url: 'http://111.229.120.67/gen/all-course-list',
        //获取课程名
        // console.log(data)
        dataType: "json",
        success: function(data) {
            if (data.statusCode == 0) {
                console.log(data)
                var course
                $.each(data.allcourseList, function(i, n) {
                    course = `
                    <p style=" display: inline-flex;" value="` + n.courseid + `">
                    <a href="#" style="display: block; text-align: center;"  >` + n.name + `</a>
                </p>`
                    $(".error-head-course").append(course)
                })
                coursecolor()
                courseajax()
            }
        },
        xhrFields: {
            withCredentials: true
        }
    })

    var nextPage


    //类型部分

    $(".error-head-class a").click(function() {
        $(this).attr("class", "cilck")
        $(this).siblings().attr("class", "color");
        // $('.content').eq($(this).index()).addClass('erron-black');
        // $('.content').eq($(this).index()).siblings().removeClass('erron-black');
    })

    function answer() {
        $(".error-content-list>ol>li").click(function() {
            $(this).attr("class", "list-cilck")
            $(this).siblings().attr("class", "")
            $('.erron-none').eq($(this).index()).addClass('erron-black');
            $('.erron-none').eq($(this).index()).siblings().removeClass('erron-black');
        })
        $("#answer").click(function() {
            $(".zhengque").attr("class", "erron-black")

        })
    }

    //打印错题
    //功能未实现
    $(".error-but").click(function() {
        // console.log(chapterid)
        $.ajax({
            type: "get",
            url: "http://111.229.120.67/stu/out-all-err-question", //接口
            data: {

            },
            dataType: "json",
            success: function(data) {

            }

        })
    })


})